
function MagicProc1_0(launcherID, posX, posY)
	-- Intone step 2000ms
	--print("开始吟唱\n")
	print("Start Instone...");
	SetNextStepTime(2000);   --吟唱2S
end

function MagicProc1_2(launcherID, posX, posY)
	-- 对目标逐个进行相关操作  -- 这里主要是定时器部分的动作哦
	local index = 0;
	local targetID = GetTargetByIndex(index);
	while targetID > 0 do
		local isAlive = IsAlive(targetID);
		if (isAlive>0 or isAlive ~= nil) then
			BeDamage(targetID, 100);

			index = index + 1;
			targetID = GetTargetByIndex(index);
		else
			print("目标已经死亡\n");
		end
	end
end

function MagicProc1_1(launcherID, posX, posY)
	print("释放阶段\n");
	print("开始收集目标\n");
	CollectionLine();   
	targetID = GetTargetByIndex(0);
	targetPosX = GetPosX(targetID);
	targetPosY = GetPosY(targetID);
	MoveTo(launcherID, targetPosX, targetPosY);  -- 玩家移动到目标单位处
	MagicProc1_2(laucherID, posX, posY);
end

function MagicProc1_5(launcherID, posX, posY)
	MagicProc1_2(launcherID, posX, posY);

	MagicEnd(launcherID);
	SetMagicCDTime(4000);
end

MagicProc1_SubAction = 
{
	MagicProc1_0
	, MagicProc1_1
	, MagicProc1_2
	, MagicProc1_2
	, MagicProc1_2
	, MagicProc1_5
}

function MagicProc1(launcherID, posX, posY, step)
	if step > 7 then 
		return
	end

	MagicProc1_SubAction[step](launcherID, posX, posY)
end

function MagicProc2(launcherID, posX, posY, step)
	print("释放2号技能，哈哈，还没有实现哦~")
end

MagicProcFuncs = 
{
	MagicProc1      -- 1号技能
	, MagicProc2    -- 2号技能
}

function DoMagic_bk(launcherID)
	local curLauncherID = launcherID
	local curStep = 1;
	local curMagicId = 0;
	local curPosX = 0;
	local curPosY = 0;

	return function(magicId, posX, posY)
		if magicId > 0 then
			curStep = 1;
			curMagicId = magicId;
			curPosX = posX;
			curPosY = posY;
		end
		--print("开始释放技能\n");
		print("Start Launch Magic...\n");
		if magicId > 2 then
			return;
		end

		-- MagicProcFuncs[curMagicId](curLauncherID, curPosX, curPosY, curStep); -- 待完善异常处理
		curStep = curStep+1;
	end
end


function DoMagic(launcherID)
	local curLauncherID = launcherID
	local curStep = 1;
	local curMagicId = 0;
	local curPosX = 0;
	local curPosY = 0;

	return function(magicId, posX, posY)
		if magicId > 0 then
			curStep = 1;
			curMagicId = magicId;
			curPosX = posX;
			curPosY = posY;
		end
		print("开始释放技能\n");
		print("Start Launch Magic...\n");
		if magicId > 2 then
			print("MagicId error\n");
			return;
		end
		curStep = curStep+1;
	end
end
